package org.gourpg.entity.dictionary;


import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.proxy.HibernateProxy;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Objects;

/**
 * 参数配置实体
 */
@Getter
@Setter
@ToString
@RequiredArgsConstructor
@Entity
@Table(name = "param_detail")
public class ParamDetail {
    @Id
    private Long id;
    /**
     * 参数对象名称，主键不能有名字
     */
    private String paramObject;
    /**
     * 参数值
     */
    private String paramValue;
    /**
     * 参数名称
     */
    private String paramName;
    /**
     * 参数说明
     */
    private String paramRemark;

    @Override
    public final boolean equals(Object o) {
        if (this == o) return true;
        if (o == null) return false;
        Class<?> oEffectiveClass = o instanceof HibernateProxy ? ((HibernateProxy) o).getHibernateLazyInitializer().getPersistentClass() : o.getClass();
        Class<?> thisEffectiveClass = this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass() : this.getClass();
        if (thisEffectiveClass != oEffectiveClass) return false;
        ParamDetail that = (ParamDetail) o;
        return getId() != null && Objects.equals(getId(), that.getId());
    }

    @Override
    public final int hashCode() {
        return this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass().hashCode() : getClass().hashCode();
    }
}
